package service

import (
	"context"
	"fmt"
	__ "user-srv/basic/proto"
	"user-srv/handler/dao"
)

// 勋章添加
func (s *Server) UserBadgesAdd(_ context.Context, in *__.UserBadgesAddReq) (*__.UserBadgesAddResp, error) {
	if in.UserId == 0 || in.RulesId == 0 {
		return nil, fmt.Errorf("参数不能为空")
	}

	add, err := dao.UserBadgesAdd(in)
	if err != nil {
		return nil, err
	}

	return &__.UserBadgesAddResp{
		Id: add.Id,
	}, nil
}

// 勋章展示
func (s *Server) UserBadgesFind(_ context.Context, in *__.UserBadgesFindReq) (*__.UserBadgesFindResp, error) {
	find, err := dao.UserBadgesFind(in)
	if err != nil {
		return nil, fmt.Errorf(err.Error())
	}

	return &__.UserBadgesFindResp{
		List: find,
	}, nil
}
